<?php

namespace App\Http\Controllers\H5;
use App\Http\Controllers\BaseController;
use App\Params\H5\AccountRechargeLogParams;
use App\Params\H5\AccountRechargeParams;
use App\Services\Account\AccountService;
use App\Traits\VerifyRequestParam;

/**
 * 账户相关控制器
 *
 * @author WangBin
 * @date 2021-09-17
 * @package App\Http\Controllers\H5
 */
class AccountController extends BaseController
{
    use VerifyRequestParam;

    /**
     * 获取充值套餐
     *
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\BusinessException
     */
    public function getPlanList()
    {
        $plan = AccountService::getInstance()->getPlan();
        return $this->success($plan);
    }

    /**
     * 账户充值
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function recharge()
    {
        $param = AccountRechargeParams::create();
        $balance = AccountService::getInstance()->recharge($param);
        return $this->success($balance);
    }

    /**
     * 获取账户充值记录
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function getRechargeLog()
    {
        $param = AccountRechargeLogParams::create();
        $logs = AccountService::getInstance()->getLogList($param);
        return $this->success($logs);
    }
}
